package test;

/**
 * TREE GENERATOR
 * @author BaciL
 *
 */

	/**
	 * Hard to describe every part of this method properly
	 * maybe this image will help http://screenshot.cz/P5LOE/TreeGen.png
	 * @param x
	 * @param y
	 */

	/*
	public void createTree(int x, int y){
		if(x < 3 | x > mapWidth - 3) return;
		blocks[x][y].setBlockType(DataManager.Type.BLOCK_TREE_BOTTOM);
		
		boolean stop = false;
		int rand = new Random().nextInt(3);
		y++;
		
		switch(rand){
			case 0:
				blocks[x-1][y].setBlockType(DataManager.Type.BLOCK_TREE_MIDDLE_LEFT);
				blocks[x-2][y].setBlockType(DataManager.Type.BLOCK_TREE_LEAVES_LEFT);
			break;
			
			case 1:
				blocks[x][y].setBlockType(DataManager.Type.BLOCK_TREE_MIDDLE);
			break;
			
			case 2:
				blocks[x+1][y].setBlockType(DataManager.Type.BLOCK_TREE_MIDDLE_RIGHT);
				blocks[x+2][y].setBlockType(DataManager.Type.BLOCK_TREE_LEAVES_RIGHT);
			break;
		}
		
		y++;
		blocks[x][y].setBlockType(DataManager.Type.BLOCK_TREE_MIDDLE);
		
		rand = new Random().nextInt(4);
		y++;
		
		switch(rand){
			case 0:
				blocks[x-1][y].setBlockType(DataManager.Type.BLOCK_TREE_MIDDLE_LEFT);
				blocks[x-2][y].setBlockType(DataManager.Type.BLOCK_TREE_LEAVES_LEFT);
			break;
			
			case 1:
				blocks[x][y].setBlockType(DataManager.Type.BLOCK_TREE_MIDDLE);
			break;
			
			case 2:
				blocks[x+1][y].setBlockType(DataManager.Type.BLOCK_TREE_MIDDLE_RIGHT);
				blocks[x+2][y].setBlockType(DataManager.Type.BLOCK_TREE_LEAVES_RIGHT);
			break;
			
			case 3:
				createTreeTop(x,y);	
				stop = true;
			break;
		}
		
		if(stop) return;
		y++;
		blocks[x][y].setBlockType(DataManager.Type.BLOCK_TREE_MIDDLE);
		y++;

		switch(rand){
			case 0:
				blocks[x-1][y].setBlockType(DataManager.Type.BLOCK_TREE_MIDDLE_LEFT);
				blocks[x-2][y].setBlockType(DataManager.Type.BLOCK_TREE_LEAVES_LEFT);
			break;
			
			case 1:
				blocks[x][y].setBlockType(DataManager.Type.BLOCK_TREE_MIDDLE);
			break;
			
			case 2:
				blocks[x+1][y].setBlockType(DataManager.Type.BLOCK_TREE_MIDDLE_RIGHT);
				blocks[x+2][y].setBlockType(DataManager.Type.BLOCK_TREE_LEAVES_RIGHT);
			break;
			
			case 3:
				createTreeTop(x,y);	
				stop = true;
			break;
		}
		
		if(stop) return;
		y++;
		createTreeTop(x,y);
	}
	
	private void createTreeTop(int x, int y){
		blocks[x][y].setBlockType(DataManager.Type.BLOCK_TREETOP_BOTTOM_MIDDLE);
		blocks[x-1][y].setBlockType(DataManager.Type.BLOCK_TREETOP_BOTTOM_LEFT);
		blocks[x+1][y].setBlockType(DataManager.Type.BLOCK_TREETOP_BOTTOM_RIGHT);
		y++;
		blocks[x][y].setBlockType(DataManager.Type.BLOCK_TREETOP_MIDDLE_MIDDLE);
		blocks[x-1][y].setBlockType(DataManager.Type.BLOCK_TREETOP_MIDDLE_LEFT);
		blocks[x+1][y].setBlockType(DataManager.Type.BLOCK_TREETOP_MIDDLE_RIGHT);
		y++;
		blocks[x][y].setBlockType(DataManager.Type.BLOCK_TREETOP_TOP_MIDDLE);
		blocks[x-1][y].setBlockType(DataManager.Type.BLOCK_TREETOP_TOP_LEFT);
		blocks[x+1][y].setBlockType(DataManager.Type.BLOCK_TREETOP_TOP_RIGHT);
	}*/
